<cfparam name="theMethod" default="">
<cfparam name="theView" default="listRegistrations">
<cfparam name="registrationID" default="0" type="integer">

<cfswitch expression="#theMethod#">

	<cfcase value="verifyRegistration">
		<cfparam name="registrationID" type="integer">
		<cfquery name="VerifyRegistration" datasource="#datasourcename#">
			update scholarship_registrations
			set scr_verified = <cfqueryparam cfsqltype="cf_sql_bit" value="1">
			where scr_registrationid = <cfqueryparam cfsqltype="cf_sql_integer" value="#registrationID#">
		</cfquery>
		
		<cfquery name="GetRegistration" datasource="#datasourcename#">
			select *
			from scholarship_registrations
			where scr_registrationid = <cfqueryparam cfsqltype="cf_sql_integer" value="#registrationID#">
		</cfquery>
		
		<cfset emailTo = "#GetRegistration.scr_email#">
		<cfset emailFrom = "cashforcollege@lachamber.org">
		
		<cfmail to="#emailTo#" from="#emailFrom#" subject="College Scholarship Enrollment Verification Received" type="HTML">
		<cfoutput>
		<p>Dear #GetRegistration.scr_firstname# #GetRegistration.scr_lastname#,</p>
		
		<p>Congratulations on your scholarship!  Thank you for completing the California Cash for College Scholarship Claim Process. Your scholarship check will be mailed to the financial aid at your fall campus and can be claimed through that office.  Questions? Check the <a href="http://www.calgrants.org/index.cfm?navID=158">Scholarship FAQs</a> or email <a href="mailto:#emailFrom#">#emailFrom#</a>.</p>
		</cfoutput>
		</cfmail>
		
	</cfcase>
	
	<cfcase value="unverifyRegistration">
		<cfparam name="registrationID" type="integer">
		<cfquery name="UnverifyRegistration" datasource="#datasourcename#">
			update scholarship_registrations
			set scr_verified = <cfqueryparam cfsqltype="cf_sql_bit" value="0">
			where scr_registrationid = <cfqueryparam cfsqltype="cf_sql_integer" value="#registrationID#">
		</cfquery>
	</cfcase>
	
	<cfcase value="deleteRegistration">
		<cfparam name="registrationID" type="integer">
		<cfquery name="DeleteRegistration" datasource="#datasourcename#">
			delete from scholarship_registrations
			where scr_registrationid = <cfqueryparam cfsqltype="cf_sql_integer" value="#registrationID#">
		</cfquery>
	</cfcase>

</cfswitch>

<cfquery name="GetRegistrations" datasource="#datasourcename#">
	select *
	from scholarship_registrations
	order by scr_lastname
</cfquery>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
<style type="text/css">
 td, p, a {
 	font-size: 11px;
	font-family: Arial, Helvetica, sans-serif;
	}
</style>
</head>

<body>

<cfswitch expression="#theView#">

	<cfcase value="listRegistrations">
	
		<cfoutput><p><a href="#script_name#?theView=exportFormat" target="_blank">Export to Excel</a></p></cfoutput>
		
		<table border="1" cellpadding="4" cellspacing="0" width="100%" align="center">
			<tr>
				<td><strong>Verified</strong></td>
				<td><strong>Student</strong></td>
				<td><strong>School</strong></td>
				<td>&nbsp;</td>
			</tr>
			<cfoutput query="GetRegistrations">
			<script type="text/javascript" language="JavaScript">
				<!--
					function confirmDelete#scr_registrationid# () {
						if (confirm("Are you sure you want to delete the registration for #scr_firstname# #scr_lastname#?")) {
							document.location = "#script_name#?theMethod=deleteRegistration&registrationID=#scr_registrationid#";
						}
					}
					
					function confirmVerify#scr_registrationid# () {
						if (confirm("Are you sure you want to verify the registration for #scr_firstname# #scr_lastname#?  Doing so will send a verification e-mail message to the student.")) {
							document.location = "#script_name#?theMethod=verifyRegistration&registrationID=#scr_registrationid#";
						}
					}
				//-->
				</script>
			
				<tr valign="middle">
					<td align="center" nowrap>
					#YesNoFormat(scr_verified)#<br>
					<cfif NOT scr_verified>
<!--- 					<a href="#script_name#?theMethod=verifyRegistration&registrationID=#scr_registrationid#"> --->
					<a href="##" onClick="confirmVerify#scr_registrationid#(); return false;">Verify</a>
					<cfelse>
					<a href="#script_name#?theMethod=unverifyRegistration&registrationID=#scr_registrationid#">Un-verify</a>
					</cfif>					
					</td>
					<td>
					
					<table width="100%">
						<tr valign="top">
							<td width="50%">
							#scr_firstname# #scr_lastname#<br>
							#scr_address#<br>
							#scr_city#, #scr_state#  #scr_zipcode#
							</td>
							<td width="50%">
							DOB: #DateFormat(scr_dob, 'm/d/yyyy')#<br>
							E-mail: #scr_email#<br>
							Phone: #scr_phone#<br>
							</td>
						</tr>
					</table>
					
					</td>
					<td>
					
					<table width="100%">
						<tr valign="top">
							<td width="50%">
							#scr_school#<br>
							#scr_schooladdress#<br>
							#scr_schoolcity#, #scr_schoolstate#  #scr_schoolzipcode#
							</td>
							<td width="50%">
							Phone: #scr_schoolphone#
							</td>
						</tr>
					</table>

					</td>
					<td align="center">
					<a href="##" onClick="confirmDelete#scr_registrationid#(); return false;">Delete</a>
					</td>
				</tr>
			</cfoutput>
		</table>
	
	</cfcase>
	
	<cfcase value="exportFormat">
	
	
	<cfheader name="Content-Disposition" value="filename=ScholarshipRegistrations_#DateFormat(now(), 'yyyymmdd')#.xls">
	<cfcontent type="unknown" reset="yes">
	
	<table>
			<tr>
				<td>Verified</td>
				<td>Last Name</td>
				<td>First Name</td>
				<td>DOB</td>
				<td>Address</td>
				<td>City</td>
				<td>State</td>
				<td>Zip</td>
				<td>Phone</td>
				<td>E-mail</td>
				<td>School</td>
				<td>School Address</td>
				<td>School City</td>
				<td>School State</td>
				<td>School Zip</td>
				<td>School Phone</td>
				<td>Opt-in</td>
				<td>Date Submitted</td>
			</tr>
			<cfoutput query="GetRegistrations">
				<tr>
					<td>#YesNoFormat(scr_verified)#</td>
					<td>#scr_lastname#</td>
					<td>#scr_firstname#</td>
					<td>#DateFormat(scr_dob, 'm/d/yyyy')#</td>
					<td>#scr_address#</td>
					<td>#scr_city#</td>
					<td>#scr_state#</td>
					<td>#scr_zipcode#</td>
					<td>#scr_phone#</td>
					<td>#scr_email#</td>
					<td>#scr_school#</td>
					<td>#scr_schooladdress#</td>
					<td>#scr_schoolcity#</td>
					<td>#scr_schoolstate#</td>
					<td>#scr_schoolzipcode#</td>
					<td>#scr_schoolphone#</td>
					<td>#YesNoFormat(scr_optin)#</td>
					<td>#DateFormat(scr_datesubmitted, 'm-d-yyyy')#</td>
				</tr>
			</cfoutput>
		</table>
	
	</cfcase>

</cfswitch>


</body>
</html>
